package org.example.hadoop3;

import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.io.WritableComparator;

/**
 * job.setSortComporatorClass()
 */
public class FlowWritableComparator extends WritableComparator {
    public FlowWritableComparator() {
        super((Class<? extends WritableComparable>) FlowBeanNew.class, true);
    }

    @Override
    public int compare(WritableComparable a, WritableComparable b) {
        FlowBeanNew fa = (FlowBeanNew) a;
        FlowBeanNew fb = (FlowBeanNew) b;
        return -fa.getSumFlow().compareTo(fb.getSumFlow());
    }
}
